//
//  GQFamousCell.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/11.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQHomeFamousCell.h"
#define kFamousMargin 20

@interface GQHomeFamousCell ()

@property (weak, nonatomic) UIButton *iconImage;
@property (weak, nonatomic) UIImageView *vertify;
@property (weak, nonatomic) UILabel *nameLabel;
@property (weak, nonatomic) UILabel *honourLabel;
@property (weak, nonatomic) UIButton *concernBtn;

@end
@implementation GQHomeFamousCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpChildView];
    }
    return self;
}

- (void)setUpChildView
{
    //创建头像

    UIButton *iconImage = [[UIButton alloc] init];
    self.iconImage = iconImage;
    [iconImage setImage:[UIImage imageWithRoundName:@"icon"] forState:UIControlStateNormal];
    //创建认证用户
    UIImageView *vertify = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"relationship_famous_accreditation"]];
    self.vertify = vertify;
    
    [iconImage addSubview:vertify];
    [self addSubview:iconImage];
    
    //创建姓名标签
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"杭电";
    nameLabel.font = [UIFont systemFontOfSize:14];
    self.nameLabel = nameLabel;
    [self addSubview:nameLabel];
    
    //创建头衔标签
    UILabel *honourLabel = [[UILabel alloc] init];
    honourLabel.font = [UIFont systemFontOfSize:12];
    honourLabel.text = @"中国书画协会名誉会长";
    honourLabel.textColor = [UIColor lightGrayColor];
    self.honourLabel = honourLabel;
    [self addSubview:honourLabel];
    
    UIButton *concernBtn = [[UIButton alloc] init];
    [concernBtn setImage:[UIImage imageNamed:@"relationship_concern"] forState:UIControlStateNormal];
    [concernBtn setImage:[UIImage imageNamed:@"relationship_concerned"] forState:UIControlStateSelected];
    [concernBtn addTarget:self action:@selector(concernBtnDidClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:concernBtn];
    self.concernBtn = concernBtn;
    
}

- (void)concernBtnDidClick:(UIButton *)btn
{

    btn.selected = !btn.selected;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat iconWidth = 40;
    CGFloat vertifyWidth = 15;
    CGFloat concernMargin = 15;
    CGFloat concernWidth = 57;
    CGFloat concernHeight = 25;
    
    self.iconImage.frame = CGRectMake(10, 10, iconWidth, iconWidth);
    
    self.vertify.x = self.iconImage.width - vertifyWidth;
    self.vertify.y = self.iconImage.height - vertifyWidth;
    self.vertify.width = vertifyWidth;
    self.vertify.height = vertifyWidth;
    
    self.nameLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImage.frame) + 20, CGRectGetMinX(self.iconImage.frame) + 5, 200, 18);
    self.honourLabel.frame = CGRectMake(self.nameLabel.x, CGRectGetMaxY(self.nameLabel.frame), 200, 18);
    self.concernBtn.frame = CGRectMake(self.width - concernMargin - concernWidth, (self.height - concernHeight) / 2, concernWidth, concernHeight);
    
    
}

@end
